package com.sinochem.yunlian.ship.base.rpc;

import com.sinochem.yunlian.ship.api.vo.bs.BsMessageSysVO;
import com.sinochem.yunlian.ship.base.biz.BsMessageSysBiz;
import com.sinochem.yunlian.ship.base.entity.BsMessageSys;
import com.sinochem.yunlian.ship.common.annotation.IgnoreToken;
import com.sinochem.yunlian.ship.common.enums.BsMsgSysStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@IgnoreToken
@RestController
@RequestMapping("api")
public class BsSmsRest {

    @Autowired
    private BsMessageSysBiz messageSysBiz;






    /**
     * 根据用户id获取系统推送信息
     * @param userId
     * @return
     */
    @RequestMapping("/sms/getMsg")
    public List<BsMessageSysVO> getSysMsg(Long userId){
        List<BsMessageSysVO> msg = messageSysBiz.getSysMsg(userId);
        return msg;
    }

    /**
     * 设置消息失效
     * @param msgId
     * @return
     */
    @RequestMapping("/sms/invalideMsg")
    public void setMsgInvalid(Long msgId){
        BsMessageSys msg = messageSysBiz.selectById(msgId);
        msg.setStatus(BsMsgSysStatus.invalide.getStatus());
        messageSysBiz.updateById(msg);

    }
}
